//
//  modelForKVO.m
//  KVO
//
//  Created by 李广帅 on 16/11/28.
//  Copyright © 2016年 刘桂林. All rights reserved.
//

#import "modelForKVO.h"

@implementation modelForKVO
//创建单例对象
+ (modelForKVO *)sharedManager
{
    static modelForKVO *sharedAccountManagerInstance = nil;
    static dispatch_once_t predicate;
    dispatch_once(&predicate, ^{
        sharedAccountManagerInstance = [[self alloc] init];
    });
    return sharedAccountManagerInstance;
}
//类方法创建对象并赋值
+(modelForKVO *)methodModelForKVO:(NSDictionary *)dic;
{
    modelForKVO *model = [modelForKVO sharedManager];
    
    //二，KVC触发KVO，改变键所对应的值
    [model setValuesForKeysWithDictionary:dic];
    
    [model setValue:@"" forKey:@"name"];
    
    return model;
}
//防止模型性质与字典key出现不匹配的情况
-(void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    
}
-(id)valueForUndefinedKey:(NSString *)key
{
    return nil;
}




@end
